class Time {
    public static instance: Time;
    detalTime: number = 16;
    fps: number = 0;
    private lastTime: number;
    constructor() {
        this.step()
    }
    public static getInstance() {
        if (!Time.instance) {
            Time.instance = new Time();
        }
        return Time.instance
    }
    private step() {
        const now = Date.now();
        this.lastTime = !this.lastTime ? now : this.lastTime
        this.fps += 1;
        const time = now - this.lastTime
        if (time > 1000) {
            this.detalTime = this.fps / 1000
            this.fps = 0;
            this.lastTime = now;
        }
        window.requestAnimationFrame(this.step.bind(this));
    }

}

export default Time.getInstance()

